<?php

        //echo "Hej Jesper <BR>";

        include 'dbconf.php';
        include 'dbopen.php';
        include 'functions.php';



        $trimmed_genesym = "SORT1";

        //$db_prepare
        $mysqli = new mysqli($dbhost, $dbuser, $dbpass, $dbname );
        //$mysqli = new mysqli("localhost", "my_user", "my_password", "world");

/* check connection */
if ($mysqli->connect_errno) {
    printf("Connect failed: %s\n", $mysqli->connect_error);
    exit();
}
else {
    printf("kallekule");
}

        $stmt = $mysqli->stmt_init();

        //$stmt->prepare(getProbeIdFromGeneSymbol2);
        //SELECT DISTINCT probe_id, gene_sym FROM gene_names_symbols WHERE gene_sym = '$genesym'";
        $stmt->prepare(getProbeIdFromGeneSymbol());
        $stmt->bind_param('s', $trimmed_genesym);
        $stmt->execute();
        $stmt->bind_result($probe_id_test);
        while($stmt->fetch()) {
                echo "$probe_id_test";
                //echo "$gene_sym";
            }

                echo "<br> next <br>";

       $stmt->close();

       $stmt2 = $mysqli->stmt_init();
//     $stmt2->prepare("SELECT t1.ind_nbr, t1.?, t2.ind_nbr, t2.exp_level FROM clinical_data AS t1 INNER JOIN exp_level AS t2 ON t1.ind_nbr = t2.ind_nbr AND t2.probe_id =? AND tissue_type =?");
//     $stmt2->prepare("SELECT t1.ind_nbr, t1.General_Data__Age, t2.ind_nbr, t2.exp_level FROM clinical_data AS t1 INNER JOIN exp_level AS t2 ON t1.ind_nbr = t2.ind_nbr AND t2.probe_id =? AND tissue_type =?");
       $stmt2->prepare("select t1.ind_nbr, t1.General_Data__Control, t2.ind_nbr, t2.exp_level FROM clinical_data as t1 inner join exp_level AS t2 ON t1.ind_nbr = t2.ind_nbr AND t2.probe_id =? AND tissue_type =?");

       $individual_probe_id='212797_at';
       $input_tissue='cpt';
//     $stmt2->bind_param('sss', $individual_clinical_var, $individual_probe_id, $input_tissue);
       $stmt2->bind_param('ss', $input_tissue, $individual_probe_id);


                $stmt2->execute();
                $stmt2->bind_result($col1,$col2, $col3, $col4);
                $columns = $stmt2->field_count;
                $rows = $stmt2->num_rows;
                echo "$columns<br>$rows<br>";
       while ($stmt2->fetch()) {
                echo "$col1"."$col2"."$col3"."$col4";
                echo "<br>";

       }

       $stmt2->close();


?>
